<template>
    <div>
        <r-search :searchForm="searchForm" :searchHandle="searchHandle" :searchData="searchData" />
        <r-table :isSelection="false" :isIndex="false" :isPagination="true" :tableData="tableData" :tableCols="tableCols" :tablePage="tablePage" @refresh="init()"></r-table>
    </div>
</template>
<script>
export default {
    data() {
        return {
            searchData: {
                orderNo: '',
                replenishName: '',
                phone: '',
            },
            searchForm: [
                {
                    type: 'input',
                    prop: 'orderNo',
                    placeholder: '工单编号',
                    width: 150
                },
                {
                    type: 'input',
                    prop: 'replenishName',
                    placeholder: '补货员名称',
                    width: 170
                },
                {
                    type: 'input',
                    prop: 'phone',
                    placeholder: '联系方式',
                    width: 170
                },
            ],
            searchHandle: [
                {
                    label: '搜索',
                    type: 'success',
                    icon: 'el-icon-search',
                    handle: e => this.init()
                },
                {
                    label: '重置',
                    icon: 'el-icon-refresh-right',
                    handle: e => this.searchFromReset()
                }
            ],
            tableData: [
            ],
            tableCols: [
                {
                    label: '工单编号',
                    prop: 'id',
                    // theme: e => e.status ? 'primary' : 'danger', type: "tag",
                },

                {
                    label: '设备编号',
                    prop: 'equipmentNo'
                },
                {
                    label: '补货员',
                    prop: 'replenishName'
                },
                {
                    label: '设备编号',
                    prop: 'equipmentNo'
                },
                {
                    label: '电话号码',
                    prop: 'phone'
                },
                {
                    label: '补货时间',
                    prop: 'ctime',
                    width: 160,
                    formatter: e => e.ctime && this.getDeta(+new Date(e.ctime.replace(/T/g, ' ')))
                },
                {
                    label: '操作',
                    type: "button",
                    btnList: [
                        {
                            label: '补货详情',
                            type: 'primary',
                            // isShow: e => e.orderId == '123' ? true : false,
                            handle: (row) => this.$router.push({ path: 'replenishment-freshDetail', query: { id: row.id } })
                        },
                    ]
                }
            ],
            tablePage: { limit: 10, page: 1, total: 0 },
        };
    },
    components: {},
    computed: {},
    mounted() {
        this.init()
    },
    methods: {
        async init() {
            let param = { ...this.searchData, ...this.tablePage }
            let res = await this.api.replenishRep(param)
            if (res) {
                this.tableData = res.data.list
                this.tablePage.total = res.data.total
            }
        },
        elFormSubmit(e) {
            //查询
            console.log(e)
        },
        elFormDetail(row) {
            Object.keys(this.formData).forEach(key => {
                this.formData[key] = row[key]
            })
            this.formData.id = row.id;
            this.formData.cardId = row.cardId
            // if (this.formCols[1].label == '登录密码') {
            //     this.formCols.splice(1, 1)
            // }

            this.elFormVisible()
        },
    }
};
</script>
<style scoped lang='scss'>
.el-icon-search {
  margin-right: 10px;
}
.Tip {
  margin-left: 20px;
}
</style>
